// ==UserScript==
// @name           phpBB Custom Smilies
// @namespace      http://glenncarr.com/greasemonkey/phpbb
// @description    Make Custom Smilies Available
// @include        *posting.php*
// @author         Glenn Carr (glenn at glenncarr dot com)
// $LastChangedRevision: 182 $
// $LastChangedDate: 2007-07-18 13:42:14 +0000 (Wed, 18 Jul 2007) $
// ==/UserScript==

(function(){

var smileyBox = document.getElementById( 'smiley-box' );
if ( !smileyBox )
    return;

var customSmilies = new Array(
'http://glenncarr.com/bananas/Banane01.gif',
'http://glenncarr.com/bananas/Banane02.gif',
'http://glenncarr.com/bananas/Banane03.gif',
'http://glenncarr.com/bananas/Banane04.gif',
'http://glenncarr.com/bananas/Banane05.gif',
'http://glenncarr.com/bananas/Banane06.gif',
'http://glenncarr.com/bananas/Banane07.gif',
'http://glenncarr.com/bananas/Banane08.gif',
'http://glenncarr.com/bananas/Banane09.gif',
'http://glenncarr.com/bananas/Banane10.gif',
'http://glenncarr.com/bananas/Banane11.gif',
'http://glenncarr.com/bananas/Banane12.gif',
'http://glenncarr.com/bananas/Banane13.gif',
'http://glenncarr.com/bananas/Banane14.gif',
'http://glenncarr.com/bananas/Banane15.gif',
'http://glenncarr.com/bananas/Banane17.gif',
'http://glenncarr.com/bananas/Banane18.gif',
'http://glenncarr.com/bananas/Banane19.gif',
'http://glenncarr.com/bananas/Banane21.gif',
'http://glenncarr.com/bananas/Banane22.gif',
'http://glenncarr.com/bananas/Banane23.gif',
'http://glenncarr.com/bananas/Banane25.gif',
'http://glenncarr.com/bananas/Banane26.gif',
'http://glenncarr.com/bananas/Banane27.gif',
'http://glenncarr.com/bananas/Banane28.gif',
'http://glenncarr.com/bananas/Banane29.gif',
'http://glenncarr.com/bananas/Banane30.gif',
'http://glenncarr.com/bananas/Banane31.gif',
'http://glenncarr.com/bananas/Banane32.gif',
'http://glenncarr.com/bananas/Banane33.gif',
'http://glenncarr.com/bananas/Banane34.gif',
'http://glenncarr.com/bananas/Banane35.gif',
'http://glenncarr.com/bananas/Banane36.gif',
'http://glenncarr.com/bananas/Banane37.gif',
'http://glenncarr.com/bananas/Banane38.gif',
'http://glenncarr.com/bananas/Banane39.gif',
'http://glenncarr.com/bananas/Banane40.gif',
'http://glenncarr.com/bananas/Banane41.gif',
'http://glenncarr.com/bananas/Banane42.gif',
'http://glenncarr.com/bananas/Banane43.gif',
'http://glenncarr.com/bananas/Banane44.gif',
'http://glenncarr.com/bananas/Banane45.gif',
'http://glenncarr.com/bananas/Banane46.gif',
'http://glenncarr.com/bananas/Banane47.gif',
'http://glenncarr.com/bananas/Banane48.gif',
'http://glenncarr.com/bananas/Banane49.gif',
//'http://glenncarr.com/bananas/Banane50.gif',
'http://glenncarr.com/bananas/Banane51.gif',
'http://glenncarr.com/bananas/Banane52.gif',
'http://glenncarr.com/bananas/Banane53.gif',
'http://glenncarr.com/bananas/Banane54.gif',
'http://glenncarr.com/bananas/Banane57.gif',
'http://glenncarr.com/bananas/Banane59.gif',
'http://glenncarr.com/bananas/banana2.gif',
'http://glenncarr.com/bananas/bananajump.gif',
'http://glenncarr.com/bananas/bananalama.gif',
'http://glenncarr.com/bananas/bananapartyhat.gif',
'http://glenncarr.com/bananas/bananapowerslide.gif',
//'http://glenncarr.com/bananas/banane58.gif',
'http://glenncarr.com/bananas/evilB.gif',
//'http://glenncarr.com/bananas/hititbanana.gif',
'http://glenncarr.com/bananas/not_ripe.gif',
'http://glenncarr.com/bananas/purplebananna.gif',
'http://glenncarr.com/bananas/smilingface.gif',
'http://glenncarr.com/bananas/woot.gif'
//'http://glenncarr.com/bananas/xena_banana.gif'
);

var insertAfter = null;
var links = smileyBox.getElementsByTagName( 'a' );
for ( var i = 0; i < links.length; i++ )
{
	if ( /view more/i.test( links[ i ].innerHTML ) )
	{
		var insertAfter = links[ i ];
		break;
	}
}
if ( !insertAfter )
{
	var smilies = smileyBox.getElementsByTagName( 'img' );
	if ( smilies.length > 0 )
		insertAfter = smilies[ smilies.length - 1 ].parentNode;
}

var div = document.createElement( 'div' );
div.setAttribute( "style", "overflow: auto; height: 150px" );
div.innerHTML = '<br/><strong>Custom Smilies</strong><br/>';
smileyBox.insertBefore( div, insertAfter.nextSibling );
insertAfter = div.lastChild;

for ( var iNewSmiley = 0; iNewSmiley < customSmilies.length; iNewSmiley++ )
{
    var newSmiley = document.createElement( 'a' );
    var smileyUrl = customSmilies[ iNewSmiley ];
    newSmiley.innerHTML = '<img title="' + customSmilies[ iNewSmiley ] + '" alt="' + customSmilies[ iNewSmiley ] + '" src="' + smileyUrl + '"/>';
    newSmiley.href = '#';
    newSmiley.setAttribute( "onclick", "insert_text('[img]" + smileyUrl + "[/img]', true); return false;" );
    div.insertBefore( newSmiley, insertAfter.nextSibling );
    insertAfter = newSmiley;
}

})();